package com.legal.aid.app.service.impl;

import com.legal.aid.app.domain.vo.ConsultVo;
import com.legal.aid.app.mapper.AppConsultMapper;
import com.legal.aid.app.service.IAppConsultService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class AppConsultServiceImpl implements IAppConsultService {
    @Autowired
    private AppConsultMapper appConsultMapper;

    @Override
    public ConsultVo getConsultStatus(Long userId, Long lawyerId) {
        ConsultVo consultVo = appConsultMapper.selectConsultStatus(userId, lawyerId);
        if(consultVo == null){
            consultVo = new ConsultVo();
            consultVo.setStatus("ended");
        }
        return consultVo;
    }

    @Override
    public boolean confirmEndConsult(Long consultId) {
        // 结束咨询，状态设为 ended
        return appConsultMapper.updateConsultStatus(consultId, "ended") > 0;
    }

}